from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModRepeatProRep import RepeatProRep, repeatProRepSchema
from database import Session, engine
import datetime


def get_Repeat_Pro_Rep(session, begin_time: datetime, end_time: datetime, openid: str):
    # 重复处理问题统计表
        connection = engine.raw_connection()
        try:
            cursor = connection.cursor()
            cursor.callproc("statics_repeat_problem", (begin_time, end_time, openid))
            cursor.close()
            connection.commit()
            repeat_pro = session.query(RepeatProRep).filter(RepeatProRep.openid == openid).all()
            return JSONResponse(repeatProRepSchema.dump(repeat_pro, many=True).data)
        finally:
            connection.close()